import { FormItemRule, TreeOption } from 'naive-ui'

// 表单项的选项类型，用于下拉选择框、复选框和单选框等组件的选项列表
export interface LabelValue {
  label: string
  value: number | string | null
  children?: LabelValue[]
}

export type FormInputType =
  | 'input'
  | 'select'
  | 'checkbox'
  | 'radio'
  | 'date-picker'
  | 'tree'
  | 'input-number'
  | 'textarea'
  | 'tree-select'

export interface FormInputItem<T, K extends keyof T> {
  key: K
  label: string
  type: FormInputType
  placeholder?: string
  options?: LabelValue[]
  rule?: FormItemRule | FormItemRule[]
  disabled?: boolean
  data?: Array<TreeOption>
  keyField?: string | number
  labelField?: string
  childrenField?: string
  labelTips?: string
  span?: number
  multiple?: boolean
}
export type FormInputList<T> = Array<FormInputItem<T, keyof T>>
export type FormInputListRules<T extends object> = {
  [K in keyof T]?: FormItemRule | FormItemRule[]
}

// 分页回显 格式
export interface PaginatedResponse<T> {
  list: T[] | []
  total: number
  page: number
  pageSize: number
}

// tag 配置
export interface TagConfig {
  text: string
  type: 'default' | 'error' | 'primary' | 'info' | 'success' | 'warning' | undefined
}

// 定义 DetailFormItem 接口
export interface DetailFormItem<T> {
  key: keyof T
  label: string
  value?: any // 确保值类型与 T 的属性类型匹配
  render?: () => any
}

// 定义 DetailsList 泛型接口
export type DetailsList<T> = Array<DetailFormItem<T>>
